/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PLELF_STRING_TABLE_H
#define PLELF_STRING_TABLE_H

#include <elf/plelfstddef.h>

namespace PLSDK {

/**
 * Manage a ELF string table from the elf header.
 */
class PLELFStringTable {
#if defined(ELF32bit)
	typedef Elf32_Addr Elf_Addr;
	typedef Elf32_Off  Elf_Off;
	typedef Elf32_Word Elf_Index;
#else
	typedef Elf64_Addr Elf_Addr;
	typedef Elf64_Off  Elf_Off;
	typedef Elf64_Word Elf_Index;
#endif
public:
	/**
	 * Constructor.
	 *
	 * @param stringTableAddress The address of the string table.
	 * @param size The size of the string table section.
	 */
	PLELFStringTable(Elf_Addr stringTableAddress, size_t size);
	/**
	 * Get the string for the index from the index table.
	 *
	 * @param index The index of the string table.
	 * @return The string from the string table.
	 */
	const char *stringFromIndex(Elf_Index index);
private:
	const char *m_tableStartPoint;
	size_t m_size;
};

}

#endif
